function createCustomElement(type, textContent, attributes) {
	var result = document.createElement(type);
	result.textContent = textContent;

	if (attributes && attributes.length > 0) {
		for (var key in attributes) {
			var attribute = attributes[key];
			var name = attribute['name'];
			var value = attribute['value'];
			result.setAttribute(name, value);
		}
	}
	return result;
}

class InjectObject {
	constructor(creator) {
		this.creator = creator
	}

	printCreator() {
		let message = 'В скрипте: ' + this.creator + ' вызван объект InjectObject()'
		var li = createCustomElement('li', message, [{ "name": "style", "value": "background: rgb(81 233 88); transition: background 0.2s ease-in-out;" }]);

		function clearColor() {
			li.style.background = '';
		}
		setInterval(clearColor, 200);

		document.querySelector('.list_li').prepend(li);
	}
}

let tr = createCustomElement('tr', '', []);
var btnInjectScriptCallContentObject = createCustomElement('button', 'Вызвать объект', [{ "name": "class", "value": "button_red" }]);
btnInjectScriptCallContentObject.addEventListener('click',
	function (e) {
		try {
			let injectScriptContentObject = new ContentObject('inject_script.js')
			injectScriptContentObject.printCreator()
		} catch (e) {
			alert('Ошибка: ' + e)
		}
	});
document.querySelector('.buttons_block').append(btnInjectScriptCallContentObject);

var btnInjectScriptCallInjectObject = createCustomElement('button', 'Вызвать объект', [{ "name": "class", "value": "button_green" }]);
btnInjectScriptCallInjectObject.addEventListener('click',
	function (e) {
		try {
			let injectScriptInjectObject = new InjectObject('inject_script.js')
			injectScriptInjectObject.printCreator()
		} catch (e) {
			alert('Ошибка: ' + e)
		}
	});
document.querySelector('.buttons_block').append(btnInjectScriptCallInjectObject);

var btnInjectScriptCallWebAppObject = createCustomElement('button', 'Вызвать объект', [{ "name": "class", "value": "button_green" }]);
btnInjectScriptCallWebAppObject.addEventListener('click',
	function (e) {
		try {
			let injectScriptWebAppObject = new WebAppObject('inject_script.js')
			injectScriptWebAppObject.printCreator()
		} catch (e) {
			alert('Ошибка: ' + e)
		}
	});
let th0 = createCustomElement('th', 'inject_script.js', [])
tr.append(th0)

let th1 = createCustomElement('th', '', [])
th1.append(btnInjectScriptCallContentObject)
tr.append(th1)

let th2 = createCustomElement('th', '', [])
th2.append(btnInjectScriptCallInjectObject)
tr.append(th2)

let th3 = createCustomElement('th', '', [])
th3.append(btnInjectScriptCallWebAppObject)
tr.append(th3)

document.querySelector('.table_block').append(tr);